home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-SPAR.{_6 / MOSTEK.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  6KB  |  162 lines

  1. /* $Id: mostek.h,v 1.10 1998/08/18 15:03:11 davem Exp $
  2.  * mostek.h:  Describes the various Mostek time of day clock registers.
  3.  *
  4.  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  5.  * Copyright (C) 1996 Thomas K. Dyas (tdyas@eden.rutgers.edu)
  6.  * Added intersil code 05/25/98 Chris Davis (cdavis@cois.on.ca)
  7.  */
  8.  
  9. #ifndef _SPARC_MOSTEK_H
  10. #define _SPARC_MOSTEK_H
  11.  
  12. #include <linux/config.h>
  13. #include <asm/idprom.h>
  14.  
  15. /*       M48T02 Register Map (adapted from Sun NVRAM/Hostid FAQ)
  16.  *
  17.  *                             Data
  18.  * Address                                                 Function
  19.  *        Bit 7 Bit 6 Bit 5 Bit 4Bit 3 Bit 2 Bit 1 Bit 0
  20.  *   7ff  -     -     -     -    -     -     -     -       Year 00-99
  21.  *   7fe  0     0     0     -    -     -     -     -      Month 01-12
  22.  *   7fd  0     0     -     -    -     -     -     -       Date 01-31
  23.  *   7fc  0     FT    0     0    0     -     -     -        Day 01-07
  24.  *   7fb  KS    0     -     -    -     -     -     -      Hours 00-23
  25.  *   7fa  0     -     -     -    -     -     -     -    Minutes 00-59
  26.  *   7f9  ST    -     -     -    -     -     -     -    Seconds 00-59
  27.  *   7f8  W     R     S     -    -     -     -     -    Control
  28.  *
  29.  *   * ST is STOP BIT
  30.  *   * W is WRITE BIT
  31.  *   * R is READ BIT
  32.  *   * S is SIGN BIT
  33.  *   * FT is FREQ TEST BIT
  34.  *   * KS is KICK START BIT
  35.  */
  36.  
  37. /* The Mostek 48t02 real time clock and NVRAM chip. The registers
  38.  * other than the control register are in binary coded decimal. Some
  39.  * control bits also live outside the control register.
  40.  */
  41.  
  42. struct mostek48t02 {
  43.     volatile char eeprom[2008];    /* This is the eeprom, don't touch! */
  44.     struct idprom idprom;        /* The idprom lives here. */
  45.     volatile unsigned char creg;    /* Control register */
  46.     volatile unsigned char sec;    /* Seconds (0-59) */
  47.     volatile unsigned char min;    /* Minutes (0-59) */
  48.     volatile unsigned char hour;    /* Hour (0-23) */
  49.     volatile unsigned char dow;    /* Day of the week (1-7) */
  50.     volatile unsigned char dom;    /* Day of the month (1-31) */
  51.     volatile unsigned char month;    /* Month of year (1-12) */
  52.     volatile unsigned char year;    /* Year (0-99) */
  53. };
  54.  
  55. extern struct mostek48t02 *mstk48t02_regs;
  56.  
  57. /* Control register values. */
  58. #define    MSTK_CREG_WRITE    0x80    /* Must set this before placing values. */
  59. #define    MSTK_CREG_READ    0x40    /* Stop updates to allow a clean read. */
  60. #define    MSTK_CREG_SIGN    0x20    /* Slow/speed clock in calibration mode. */
  61.  
  62. /* Control bits that live in the other registers. */
  63. #define    MSTK_STOP    0x80    /* Stop the clock oscillator. (sec) */
  64. #define    MSTK_KICK_START    0x80    /* Kick start the clock chip. (hour) */
  65. #define MSTK_FREQ_TEST    0x40    /* Frequency test mode. (day) */
  66.  
  67. #define MSTK_YEAR_ZERO       1968   /* If year reg has zero, it is 1968. */
  68. #define MSTK_CVT_YEAR(yr)  ((yr) + MSTK_YEAR_ZERO)
  69.  
  70. /* Masks that define how much space each value takes up. */
  71. #define    MSTK_SEC_MASK    0x7f
  72. #define    MSTK_MIN_MASK    0x7f
  73. #define    MSTK_HOUR_MASK    0x3f
  74. #define    MSTK_DOW_MASK    0x07
  75. #define    MSTK_DOM_MASK    0x3f
  76. #define    MSTK_MONTH_MASK    0x1f
  77. #define    MSTK_YEAR_MASK    0xff
  78.  
  79. /* Binary coded decimal conversion macros. */
  80. #define MSTK_REGVAL_TO_DECIMAL(x)  (((x) & 0x0F) + 0x0A * ((x) >> 0x04))
  81. #define MSTK_DECIMAL_TO_REGVAL(x)  ((((x) / 0x0A) << 0x04) + ((x) % 0x0A))
  82.  
  83. /* Generic register set and get macros for internal use. */
  84. #define MSTK_GET(regs,var,mask) (MSTK_REGVAL_TO_DECIMAL(regs->var & MSTK_ ## mask ## _MASK))
  85. #define MSTK_SET(regs,var,value,mask) do { regs->var &= ~(MSTK_ ## mask ## _MASK); regs->var |= MSTK_DECIMAL_TO_REGVAL(value) & (MSTK_ ## mask ## _MASK); } while (0)
  86.  
  87. /* Macros to make register access easier on our fingers. These give you
  88.  * the decimal value of the register requested if applicable. You pass
  89.  * the a pointer to a 'struct mostek48t02'.
  90.  */
  91. #define    MSTK_REG_CREG(regs)    (regs->creg)
  92. #define    MSTK_REG_SEC(regs)    MSTK_GET(regs,sec,SEC)
  93. #define    MSTK_REG_MIN(regs)    MSTK_GET(regs,min,MIN)
  94. #define    MSTK_REG_HOUR(regs)    MSTK_GET(regs,hour,HOUR)
  95. #define    MSTK_REG_DOW(regs)    MSTK_GET(regs,dow,DOW)
  96. #define    MSTK_REG_DOM(regs)    MSTK_GET(regs,dom,DOM)
  97. #define    MSTK_REG_MONTH(regs)    MSTK_GET(regs,month,MONTH)
  98. #define    MSTK_REG_YEAR(regs)    MSTK_GET(regs,year,YEAR)
  99.  
  100. #define    MSTK_SET_REG_SEC(regs,value)    MSTK_SET(regs,sec,value,SEC)
  101. #define    MSTK_SET_REG_MIN(regs,value)    MSTK_SET(regs,min,value,MIN)
  102. #define    MSTK_SET_REG_HOUR(regs,value)    MSTK_SET(regs,hour,value,HOUR)
  103. #define    MSTK_SET_REG_DOW(regs,value)    MSTK_SET(regs,dow,value,DOW)
  104. #define    MSTK_SET_REG_DOM(regs,value)    MSTK_SET(regs,dom,value,DOM)
  105. #define    MSTK_SET_REG_MONTH(regs,value)    MSTK_SET(regs,month,value,MONTH)
  106. #define    MSTK_SET_REG_YEAR(regs,value)    MSTK_SET(regs,year,value,YEAR)
  107.  
  108.  
  109. /* The Mostek 48t08 clock chip. Found on Sun4m's I think. It has the
  110.  * same (basically) layout of the 48t02 chip except for the extra
  111.  * NVRAM on board (8 KB against the 48t02's 2 KB).
  112.  */
  113. struct mostek48t08 {
  114.     char offset[6*1024];         /* Magic things may be here, who knows? */
  115.     struct mostek48t02 regs;     /* Here is what we are interested in.   */
  116. };
  117. extern struct mostek48t08 *mstk48t08_regs;
  118.  
  119. extern enum sparc_clock_type sp_clock_typ;
  120.  
  121. #ifdef CONFIG_SUN4
  122. enum sparc_clock_type {    MSTK48T02, MSTK48T08, \
  123. INTERSIL, MSTK_INVALID };
  124. #else
  125. enum sparc_clock_type {    MSTK48T02, MSTK48T08, \
  126. MSTK_INVALID };
  127. #endif
  128.  
  129. #ifdef CONFIG_SUN4
  130. /* intersil on a sun 4/260 code  data from harris doc */
  131. struct intersil_dt {
  132.         volatile unsigned char int_csec;
  133.         volatile unsigned char int_hour;
  134.         volatile unsigned char int_min;
  135.         volatile unsigned char int_sec;
  136.         volatile unsigned char int_month;
  137.         volatile unsigned char int_day;
  138.         volatile unsigned char int_year;
  139.         volatile unsigned char int_dow;
  140. };
  141.  
  142. struct intersil {
  143.     struct intersil_dt clk;
  144.     struct intersil_dt cmp;
  145.     volatile unsigned char int_intr_reg;
  146.     volatile unsigned char int_cmd_reg;
  147. };
  148.  
  149. #define INTERSIL_STOP        0x0
  150. #define INTERSIL_START       0x8
  151. #define INTERSIL_INTR_DISABLE   0x0
  152. #define INTERSIL_INTR_ENABLE   0x10
  153. #define INTERSIL_32K        0x0
  154. #define INTERSIL_NORMAL        0x0
  155. #define INTERSIL_24H        0x4 
  156. #define INTERSIL_INT_100HZ    0x2
  157.  
  158. /* end of intersil info */
  159. #endif
  160.  
  161. #endif /* !(_SPARC_MOSTEK_H) */
  162.